home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / graphics / motionrd.zip / KEY.ASM < prev    next >
Assembly Source File  |  1994-12-04  |  4KB  |  104 lines

  1. ; Keyboard INT 9 replacement vector by Patch - hamell@cs.pdx.edu
  2. ; Taken from my source KBDHANDx.ZIP ... this is from an older version
  3.  
  4. .model small
  5.  
  6. .code
  7. PUBLIC          _keys
  8.                 _keys           db      256 dup(0)
  9. PUBLIC          _keynumpress
  10.                 _keynumpress    db      0
  11. oldint9         dd      0
  12. e0flag          db      0
  13.  
  14.                         PUBLIC  _Set_New_Int9
  15. _Set_New_Int9           PROC    
  16.                 push    ds
  17.                 push    si
  18.                 cli
  19.  
  20.                 mov     ax,3509h                ; get old INT 9
  21.                 int     21h
  22.                 mov     si,offset oldint9
  23.                 mov     word ptr cs:[si],bx        ; save offset
  24.                 mov     word ptr cs:[si + 2],es    ; save segment
  25.  
  26.                 mov     ax,2509h                ; set new INT 9
  27.                 mov     dx,seg _New_Int9
  28.                 mov     ds,dx
  29.                 mov     dx,offset _New_Int9
  30.                 int     21h
  31.  
  32.                 sti
  33.                 pop     si
  34.                 pop     ds
  35.                 ret
  36. _Set_New_Int9           ENDP
  37.  
  38.                         PUBLIC  _Set_Old_Int9
  39. _Set_Old_Int9           PROC    
  40.                 push    ds
  41.                 push    si
  42.                 cli
  43.  
  44.                 mov     si,offset oldint9
  45.                 mov     dx,word ptr cs:[si]        ; load offset
  46.                 mov     ds,word ptr cs:[si + 2]    ; load segment
  47.                 mov     ax,2509h                ; set new INT 9
  48.                 int     21h
  49.  
  50.                 sti
  51.                 pop     si
  52.                 pop     ds
  53.                 ret
  54. _Set_Old_Int9           ENDP
  55.  
  56. _New_Int9       PROC    FAR
  57.                 push    ax
  58.                 push    bx
  59.  
  60.                 in      al,60h
  61.                 
  62.                 cmp     al,0E0h         ; was it an E0 key?
  63.                 jne     setscancode
  64.  
  65. ; E0 key routine
  66.                 mov     cs:[e0flag],128
  67.                 
  68.                 mov     al,20h          ; Send generic EOI to PIC
  69.                 out     20h,al          ; 001 00 000
  70.                                         ; |   |  | 
  71.                                         ; |   |  +---- INT request level
  72.                                         ; |   +------- OCW2
  73.                                         ; +----------- non-specific EOI command
  74.                 pop     bx
  75.                 pop     ax
  76.                 iret
  77.  
  78. setscancode:    mov     bl,al                   ; save scan code
  79.                 and     bl,01111111b
  80.                 add     bl,cs:[e0flag]
  81.                 xor     bh,bh                   ; clear for index use
  82.                 and     al,10000000b            ; keep break bit, if set
  83.                 xor     al,10000000b            ; flip bit - 1 means pressed
  84.                                                 ;          - 0 means released
  85.                 rol     al,1                    ; put it in bit 0
  86.                 mov     cs:_keys[bx],al            ; set index for key
  87.                 mov     cs:[e0flag],0              ; set E0 to 0
  88.                 shl     al,1                    ; set to 2 or 0
  89.                 dec     al                      ; 1 = press, -1 = release
  90.                 add     cs:[_keynumpress],al       ; inc or dec keypress
  91.  
  92.                 mov     al,20h          ; Send generic EOI to PIC
  93.                 out     20h,al          ; 001 00 000
  94.                                         ; |   |  | 
  95.                                         ; |   |  +---- INT request level
  96.                                         ; |   +------- OCW2
  97.                                         ; +----------- non-specific EOI command
  98.                 pop     bx
  99.                 pop     ax
  100.                 iret
  101. _New_Int9       ENDP
  102.  
  103.                 END
  104.